#include <REGX52.H>
unsigned char num;
void Delay20ms()		//@12.000MHz
{
	unsigned char i, j;

	i = 39;
	j = 230;
	do
	{
		while (--j);
	} while (--i);
}
void main()
{	
	P2=~(1<<0);
	while(1)
	{
		if(0==P3_1)
		{
			Delay20ms();
			while(0==P3_1);
			Delay20ms();
			num++;
			if(num>=8)
				num=0;
			P2=~(1<<num);
		}
		if(0==P3_0)
		{
			Delay20ms();
			while(0==P3_0);
			Delay20ms();
			if(num==0)
				num=7;
			else
				num--;
			P2=~(1<<num);
		}
	}

}
